﻿using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.Extensions.Logging;

#nullable disable

namespace Sunny.Entity
{
    public partial class SunnyContext : DbContext
    {
        public SunnyContext()
        {
        }

        public SunnyContext(DbContextOptions<SunnyContext> options)
            : base(options)
        {
        }

        public virtual DbSet<SysConfig> SysConfigs { get; set; }
        public virtual DbSet<SysDept> SysDepts { get; set; }
        public virtual DbSet<SysDictData> SysDictData { get; set; }
        public virtual DbSet<SysDictType> SysDictTypes { get; set; }
        public virtual DbSet<SysJob> SysJobs { get; set; }
        public virtual DbSet<SysJobLog> SysJobLogs { get; set; }
        public virtual DbSet<SysLoginLog> SysLoginLog { get; set; }
        public virtual DbSet<SysMenu> SysMenus { get; set; }
        public virtual DbSet<SysOperLog> SysOperLogs { get; set; }
        public virtual DbSet<SysPost> SysPosts { get; set; }
        public virtual DbSet<SysRole> SysRoles { get; set; }
        public virtual DbSet<SysRoleDept> SysRoleDepts { get; set; }
        public virtual DbSet<SysRoleMenu> SysRoleMenus { get; set; }
        public virtual DbSet<SysUser> SysUsers { get; set; }
        public virtual DbSet<SysUserPost> SysUserPosts { get; set; }
        public virtual DbSet<SysUserRole> SysUserRoles { get; set; }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            if (!optionsBuilder.IsConfigured)
            {
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see http://go.microsoft.com/fwlink/?LinkId=723263.
                optionsBuilder.UseSqlServer("data source=.;initial catalog=Sunny;user id=sa;password=Ab123456789;MultipleActiveResultSets=true;")
                    .LogTo(Console.WriteLine,LogLevel.Information);
            }
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.HasAnnotation("Relational:Collation", "SQL_Latin1_General_CP1_CI_AS");
        
            modelBuilder.Entity<SysConfig>(entity =>
            {
                entity.HasKey(e => e.ConfigId)
                    .HasName("PK__sys_conf__4AD1BFF1D294B466");
        
                entity.ToTable("sys_config");
        
                entity.HasComment("参数配置表");
        
                entity.Property(e => e.ConfigId)
                    .ValueGeneratedOnAdd()
                    .HasColumnName("config_id")
                    .HasComment("参数主键");
        
                entity.Property(e => e.ConfigKey)
                    .HasMaxLength(100)
                    .HasColumnName("config_key")
                    .HasComment("参数键名");
        
                entity.Property(e => e.ConfigName)
                    .HasMaxLength(100)
                    .HasColumnName("config_name")
                    .HasComment("参数名称");
        
                entity.Property(e => e.ConfigType)
                    .HasMaxLength(1)
                    .HasColumnName("config_type")
                    .IsFixedLength(true)
                    .HasComment("系统内置（Y是 N否）");
        
                entity.Property(e => e.ConfigValue)
                    .HasMaxLength(500)
                    .HasColumnName("config_value")
                    .HasComment("参数键值");
        
                entity.Property(e => e.CreateBy)
                    .HasMaxLength(64)
                    .HasColumnName("create_by")
                    .HasComment("创建者");
        
                entity.Property(e => e.CreateTime)
                    .HasColumnName("create_time")
                    .HasComment("创建时间");
        
                entity.Property(e => e.Remark)
                    .HasMaxLength(500)
                    .HasColumnName("remark")
                    .HasComment("备注");
        
                entity.Property(e => e.UpdateBy)
                    .HasMaxLength(64)
                    .HasColumnName("update_by")
                    .HasComment("更新者");
        
                entity.Property(e => e.UpdateTime)
                    .HasColumnName("update_time")
                    .HasComment("更新时间");
            });
        
            modelBuilder.Entity<SysDept>(entity =>
            {
                entity.HasQueryFilter(t=>t.DelFlag == 0);
                entity.HasKey(e => e.DeptId)
                    .HasName("PK__sys_dept__DCA659746F43DF28");
        
                entity.ToTable("sys_dept");
        
                entity.HasComment("部门表");
        
                entity.Property(e => e.DeptId)
                    .ValueGeneratedOnAdd()
                    .HasColumnName("dept_id")
                    .HasComment("部门id");
        
                entity.Property(e => e.Ancestors)
                    .HasMaxLength(50)
                    .HasColumnName("ancestors")
                    .HasComment("祖级列表");
        
                entity.Property(e => e.CreateBy)
                    .HasMaxLength(64)
                    .HasColumnName("create_by")
                    .HasComment("创建者");
        
                entity.Property(e => e.CreateTime)
                    .HasColumnName("create_time")
                    .HasComment("创建时间");
        
                entity.Property(e => e.DelFlag)
                    .HasMaxLength(1)
                    .HasColumnName("del_flag")
                    .IsFixedLength(true)
                    .HasComment("删除标志（0代表存在 2代表删除）");
        
                entity.Property(e => e.DeptName)
                    .HasMaxLength(30)
                    .HasColumnName("dept_name")
                    .HasComment("部门名称");
        
                entity.Property(e => e.Email)
                    .HasMaxLength(50)
                    .HasColumnName("email")
                    .HasComment("邮箱");
        
                entity.Property(e => e.Leader)
                    .HasMaxLength(20)
                    .HasColumnName("leader")
                    .HasComment("负责人");
        
                entity.Property(e => e.OrderNum)
                    .HasColumnName("order_num")
                    .HasComment("显示顺序");
        
                entity.Property(e => e.ParentId)
                    .HasColumnName("parent_id")
                    .HasComment("父部门id");
        
                entity.Property(e => e.Phone)
                    .HasMaxLength(11)
                    .HasColumnName("phone")
                    .HasComment("联系电话");
        
                entity.Property(e => e.Status)
                    .HasMaxLength(1)
                    .HasColumnName("status")
                    .IsFixedLength(true)
                    .HasComment("部门状态（0正常 1停用）");
        
                entity.Property(e => e.UpdateBy)
                    .HasMaxLength(64)
                    .HasColumnName("update_by")
                    .HasComment("更新者");
        
                entity.Property(e => e.UpdateTime)
                    .HasColumnName("update_time")
                    .HasComment("更新时间");
            });
        
            modelBuilder.Entity<SysDictData>(entity =>
            {
                entity.HasKey(e => e.DictCode)
                    .HasName("PK__sys_dict__19CBC34BCAB4E7E4");
        
                entity.ToTable("sys_dict_data");
        
                entity.HasComment("字典数据表");
        
                entity.Property(e => e.DictCode)
                    .ValueGeneratedOnAdd()
                    .HasColumnName("dict_code")
                    .HasComment("字典编码");
        
                entity.Property(e => e.CreateBy)
                    .HasMaxLength(64)
                    .HasColumnName("create_by")
                    .HasComment("创建者");
        
                entity.Property(e => e.CreateTime)
                    .HasColumnName("create_time")
                    .HasComment("创建时间");
        
                entity.Property(e => e.CssClass)
                    .HasMaxLength(100)
                    .HasColumnName("css_class")
                    .HasComment("样式属性（其他样式扩展）");
        
                entity.Property(e => e.DictLabel)
                    .HasMaxLength(100)
                    .HasColumnName("dict_label")
                    .HasComment("字典标签");
        
                entity.Property(e => e.DictSort)
                    .HasColumnName("dict_sort")
                    .HasComment("字典排序");
        
                entity.Property(e => e.DictType)
                    .HasMaxLength(100)
                    .HasColumnName("dict_type")
                    .HasComment("字典类型");
        
                entity.Property(e => e.DictValue)
                    .HasMaxLength(100)
                    .HasColumnName("dict_value")
                    .HasComment("字典键值");
        
                entity.Property(e => e.IsDefault)
                    .HasMaxLength(1)
                    .HasColumnName("is_default")
                    .IsFixedLength(true)
                    .HasComment("是否默认（Y是 N否）");
        
                entity.Property(e => e.ListClass)
                    .HasMaxLength(100)
                    .HasColumnName("list_class")
                    .HasComment("表格回显样式");
        
                entity.Property(e => e.Remark)
                    .HasMaxLength(500)
                    .HasColumnName("remark")
                    .HasComment("备注");
        
                entity.Property(e => e.Status)
                    .HasMaxLength(1)
                    .HasColumnName("status")
                    .IsFixedLength(true)
                    .HasComment("状态（0正常 1停用）");
        
                entity.Property(e => e.UpdateBy)
                    .HasMaxLength(64)
                    .HasColumnName("update_by")
                    .HasComment("更新者");
        
                entity.Property(e => e.UpdateTime)
                    .HasColumnName("update_time")
                    .HasComment("更新时间");
            });
        
            modelBuilder.Entity<SysDictType>(entity =>
            {
                entity.HasKey(e => e.DictId)
                    .HasName("PK__sys_dict__3BD4186C7D13E688");
        
                entity.ToTable("sys_dict_type");
        
                entity.HasComment("字典类型表");
        
                entity.HasIndex(e => e.DictType, "dict_type")
                    .IsUnique();
        
                entity.Property(e => e.DictId)
                    .ValueGeneratedOnAdd()
                    .HasColumnName("dict_id")
                    .HasComment("字典主键");
        
                entity.Property(e => e.CreateBy)
                    .HasMaxLength(64)
                    .HasColumnName("create_by")
                    .HasComment("创建者");
        
                entity.Property(e => e.CreateTime)
                    .HasColumnName("create_time")
                    .HasComment("创建时间");
        
                entity.Property(e => e.DictName)
                    .HasMaxLength(100)
                    .HasColumnName("dict_name")
                    .HasComment("字典名称");
        
                entity.Property(e => e.DictType)
                    .HasMaxLength(100)
                    .HasColumnName("dict_type")
                    .HasComment("字典类型");
        
                entity.Property(e => e.Remark)
                    .HasMaxLength(500)
                    .HasColumnName("remark")
                    .HasComment("备注");
        
                entity.Property(e => e.Status)
                    .HasMaxLength(1)
                    .HasColumnName("status")
                    .HasComment("状态（1正常 0停用）");
        
                entity.Property(e => e.UpdateBy)
                    .HasMaxLength(64)
                    .HasColumnName("update_by")
                    .HasComment("更新者");
        
                entity.Property(e => e.UpdateTime)
                    .HasColumnName("update_time")
                    .HasComment("更新时间");
            });
        
            modelBuilder.Entity<SysJob>(entity =>
            {
                entity.HasKey(e => new { e.JobId, e.JobName, e.JobGroup })
                    .HasName("PK__sys_job__2E0E56DC97B7D554");
        
                entity.ToTable("sys_job");
        
                entity.HasComment("定时任务调度表");
        
                entity.Property(e => e.JobId)
                    .HasColumnName("job_id")
                    .HasComment("任务ID");
        
                entity.Property(e => e.JobName)
                    .HasMaxLength(64)
                    .HasColumnName("job_name")
                    .HasComment("任务名称");
        
                entity.Property(e => e.JobGroup)
                    .HasMaxLength(64)
                    .HasColumnName("job_group")
                    .HasComment("任务组名");
        
                entity.Property(e => e.Concurrent)
                    .HasMaxLength(1)
                    .HasColumnName("concurrent")
                    .IsFixedLength(true)
                    .HasComment("是否并发执行（0允许 1禁止）");
        
                entity.Property(e => e.CreateBy)
                    .HasMaxLength(64)
                    .HasColumnName("create_by")
                    .HasComment("创建者");
        
                entity.Property(e => e.CreateTime)
                    .HasColumnName("create_time")
                    .HasComment("创建时间");
        
                entity.Property(e => e.CronExpression)
                    .HasMaxLength(255)
                    .HasColumnName("cron_expression")
                    .HasComment("cron执行表达式");
        
                entity.Property(e => e.InvokeTarget)
                    .IsRequired()
                    .HasMaxLength(500)
                    .HasColumnName("invoke_target")
                    .HasComment("调用目标字符串");
        
                entity.Property(e => e.MisfirePolicy)
                    .HasMaxLength(20)
                    .HasColumnName("misfire_policy")
                    .HasComment("计划执行错误策略（1立即执行 2执行一次 3放弃执行）");
        
                entity.Property(e => e.Remark)
                    .HasMaxLength(500)
                    .HasColumnName("remark")
                    .HasComment("备注信息");
        
                entity.Property(e => e.Status)
                    .HasMaxLength(1)
                    .HasColumnName("status")
                    .IsFixedLength(true)
                    .HasComment("状态（0正常 1暂停）");
        
                entity.Property(e => e.UpdateBy)
                    .HasMaxLength(64)
                    .HasColumnName("update_by")
                    .HasComment("更新者");
        
                entity.Property(e => e.UpdateTime)
                    .HasColumnName("update_time")
                    .HasComment("更新时间");
            });
        
            modelBuilder.Entity<SysJobLog>(entity =>
            {
                entity.HasKey(e => e.JobLogId)
                    .HasName("PK__sys_job___0CA0EBC93992076B");
        
                entity.ToTable("sys_job_log");
        
                entity.HasComment("定时任务调度日志表");
        
                entity.Property(e => e.JobLogId)
                    .ValueGeneratedNever()
                    .HasColumnName("job_log_id")
                    .HasComment("任务日志ID");
        
                entity.Property(e => e.CreateTime)
                    .HasColumnName("create_time")
                    .HasComment("创建时间");
        
                entity.Property(e => e.ExceptionInfo)
                    .HasMaxLength(2000)
                    .HasColumnName("exception_info")
                    .HasComment("异常信息");
        
                entity.Property(e => e.InvokeTarget)
                    .IsRequired()
                    .HasMaxLength(500)
                    .HasColumnName("invoke_target")
                    .HasComment("调用目标字符串");
        
                entity.Property(e => e.JobGroup)
                    .IsRequired()
                    .HasMaxLength(64)
                    .HasColumnName("job_group")
                    .HasComment("任务组名");
        
                entity.Property(e => e.JobMessage)
                    .HasMaxLength(500)
                    .HasColumnName("job_message")
                    .HasComment("日志信息");
        
                entity.Property(e => e.JobName)
                    .IsRequired()
                    .HasMaxLength(64)
                    .HasColumnName("job_name")
                    .HasComment("任务名称");
        
                entity.Property(e => e.Status)
                    .HasMaxLength(1)
                    .HasColumnName("status")
                    .IsFixedLength(true)
                    .HasComment("执行状态（0正常 1失败）");
            });
        
            modelBuilder.Entity<SysLoginLog>(entity =>
            {
                entity.HasKey(e => e.LogId)
                    .HasName("PK__sys_logi__3D8A9C1AD6A7F245");
        
                entity.ToTable("sys_login_log");
        
                entity.HasComment("系统访问记录");
        
                entity.Property(e => e.LogId)
                    .ValueGeneratedOnAdd()
                    .HasColumnName("log_id")
                    .HasComment("日志ID");
        
                entity.Property(e => e.Browser)
                    .HasMaxLength(50)
                    .HasColumnName("browser")
                    .HasComment("浏览器类型");
        
                entity.Property(e => e.Ipaddr)
                    .HasMaxLength(128)
                    .HasColumnName("ipaddr")
                    .HasComment("登录IP地址");
        
                entity.Property(e => e.LoginLocation)
                    .HasMaxLength(255)
                    .HasColumnName("login_location")
                    .HasComment("登录地点");
        
                entity.Property(e => e.LoginTime)
                    .HasColumnName("login_time")
                    .HasComment("访问时间");
        
                entity.Property(e => e.Msg)
                    .HasMaxLength(255)
                    .HasColumnName("msg")
                    .HasComment("提示消息");
        
                entity.Property(e => e.Os)
                    .HasMaxLength(50)
                    .HasColumnName("os")
                    .HasComment("操作系统");
        
                entity.Property(e => e.Status)
                    .HasMaxLength(1)
                    .HasColumnName("status")
                    .IsFixedLength(true)
                    .HasComment("登录状态（1成功 0失败）");
        
                entity.Property(e => e.UserName)
                    .HasMaxLength(50)
                    .HasColumnName("user_name")
                    .HasComment("用户账号");
            });
        
            modelBuilder.Entity<SysMenu>(entity =>
            {

                entity.HasKey(e => e.MenuId)
                    .HasName("PK__sys_menu__4CA0FADCFABDC162");
        
                entity.ToTable("sys_menu");
        
                entity.HasComment("菜单权限表");
        
                entity.Property(e => e.MenuId)
                    .ValueGeneratedOnAdd()
                    .HasColumnName("menu_id")
                    .HasComment("菜单ID");
        
                entity.Property(e => e.Component)
                    .HasMaxLength(255)
                    .HasColumnName("component")
                    .HasComment("组件路径");
        
                entity.Property(e => e.CreateBy)
                    .HasMaxLength(64)
                    .HasColumnName("create_by")
                    .HasComment("创建者");
        
                entity.Property(e => e.CreateTime)
                    .HasColumnName("create_time")
                    .HasComment("创建时间");
        
                entity.Property(e => e.Icon)
                    .HasMaxLength(100)
                    .HasColumnName("icon")
                    .HasComment("菜单图标");
        
                entity.Property(e => e.IsCache)
                    .HasColumnName("is_cache")
                    .HasComment("是否缓存（0缓存 1不缓存）");
        
                entity.Property(e => e.IsFrame)
                    .HasColumnName("is_frame")
                    .HasComment("是否为外链（0是 1否）");
        
                entity.Property(e => e.MenuName)
                    .IsRequired()
                    .HasMaxLength(50)
                    .HasColumnName("menu_name")
                    .HasComment("菜单名称");
        
                entity.Property(e => e.MenuType)
                    .HasMaxLength(1)
                    .HasColumnName("menu_type")
                    .IsFixedLength(true)
                    .HasComment("菜单类型（M目录 C菜单 F按钮）");
        
                entity.Property(e => e.OrderNum)
                    .HasColumnName("order_num")
                    .HasComment("显示顺序");
        
                entity.Property(e => e.ParentId)
                    .HasColumnName("parent_id")
                    .HasComment("父菜单ID");
        
                entity.Property(e => e.Path)
                    .HasMaxLength(200)
                    .HasColumnName("path")
                    .HasComment("路由地址");
        
                entity.Property(e => e.Perms)
                    .HasMaxLength(100)
                    .HasColumnName("perms")
                    .HasComment("权限标识");
        
                entity.Property(e => e.Remark)
                    .HasMaxLength(500)
                    .HasColumnName("remark")
                    .HasComment("备注");
        
                entity.Property(e => e.Status)
                    .HasMaxLength(1)
                    .HasColumnName("status")
                    .IsFixedLength(true)
                    .HasComment("菜单状态（0正常 1停用）");
        
                entity.Property(e => e.UpdateBy)
                    .HasMaxLength(64)
                    .HasColumnName("update_by")
                    .HasComment("更新者");
        
                entity.Property(e => e.UpdateTime)
                    .HasColumnName("update_time")
                    .HasComment("更新时间");
        
                entity.Property(e => e.Visible)
                    .HasMaxLength(1)
                    .HasColumnName("visible")
                    .IsFixedLength(true)
                    .HasComment("菜单状态（0显示 1隐藏）");
            });
            
            modelBuilder.Entity<SysOperLog>(entity =>
            {
                entity.HasKey(e => e.OperId);

                entity.ToTable("sys_oper_log");
        
                entity.HasComment("操作日志记录");
        
                entity.Property(e => e.OperId)
                    .ValueGeneratedOnAdd()
                    .HasColumnName("oper_id")
                    .HasComment("日志主键");
        
                entity.Property(e => e.BusinessType)
                    .HasColumnName("business_type")
                    .HasComment("业务类型（0其它 1新增 2修改 3删除）");
        
                entity.Property(e => e.DeptName)
                    .HasMaxLength(50)
                    .HasColumnName("dept_name")
                    .HasComment("部门名称");
        
                entity.Property(e => e.ErrorMsg)
                    .HasMaxLength(2000)
                    .HasColumnName("error_msg")
                    .HasComment("错误消息");
        
                entity.Property(e => e.JsonResult)
                    .HasColumnName("json_result")
                    .HasComment("返回参数");
        
                entity.Property(e => e.Method)
                    .HasMaxLength(100)
                    .HasColumnName("method")
                    .HasComment("方法名称");
        
                entity.Property(e => e.OperIp)
                    .HasMaxLength(128)
                    .HasColumnName("oper_ip")
                    .HasComment("主机地址");
        
                entity.Property(e => e.OperLocation)
                    .HasMaxLength(255)
                    .HasColumnName("oper_location")
                    .HasComment("操作地点");
        
                entity.Property(e => e.OperName)
                    .HasMaxLength(50)
                    .HasColumnName("oper_name")
                    .HasComment("操作人员");
        
                entity.Property(e => e.OperParam)
                    .HasColumnName("oper_param")
                    .HasComment("请求参数");
        
                entity.Property(e => e.OperTime)
                    .HasColumnName("oper_time")
                    .HasComment("操作时间");
        
                entity.Property(e => e.OperUrl)
                    .HasMaxLength(255)
                    .HasColumnName("oper_url")
                    .HasComment("请求URL");
        
                entity.Property(e => e.OperatorType)
                    .HasColumnName("operator_type")
                    .HasComment("操作类别（0其它 1后台用户 2手机端用户）");
        
                entity.Property(e => e.RequestMethod)
                    .HasMaxLength(10)
                    .HasColumnName("request_method")
                    .HasComment("请求方式");
        
                entity.Property(e => e.Status)
                    .HasColumnName("status")
                    .HasComment("操作状态（0正常 1异常）");
        
                entity.Property(e => e.Title)
                    .HasMaxLength(50)
                    .HasColumnName("title")
                    .HasComment("模块标题");
            });
        
            modelBuilder.Entity<SysPost>(entity =>
            {
                entity.HasKey(e => e.PostId)
                    .HasName("PK__sys_post__3ED78766A15984DA");
        
                entity.ToTable("sys_post");
        
                entity.HasComment("岗位信息表");
        
                entity.Property(e => e.PostId)
                    .ValueGeneratedOnAdd()
                    .HasColumnName("post_id")
                    .HasComment("岗位ID");
        
                entity.Property(e => e.CreateBy)
                    .HasMaxLength(64)
                    .HasColumnName("create_by")
                    .HasComment("创建者");
        
                entity.Property(e => e.CreateTime)
                    .HasColumnName("create_time")
                    .HasComment("创建时间");
        
                entity.Property(e => e.PostCode)
                    .IsRequired()
                    .HasMaxLength(64)
                    .HasColumnName("post_code")
                    .HasComment("岗位编码");
        
                entity.Property(e => e.PostName)
                    .IsRequired()
                    .HasMaxLength(50)
                    .HasColumnName("post_name")
                    .HasComment("岗位名称");
        
                entity.Property(e => e.PostSort)
                    .HasColumnName("post_sort")
                    .HasComment("显示顺序");
        
                entity.Property(e => e.Remark)
                    .HasMaxLength(500)
                    .HasColumnName("remark")
                    .HasComment("备注");
        
                entity.Property(e => e.Status)
                    .IsRequired()
                    .HasMaxLength(1)
                    .HasColumnName("status")
                    .IsFixedLength(true)
                    .HasComment("状态（0正常 1停用）");
        
                entity.Property(e => e.UpdateBy)
                    .HasMaxLength(64)
                    .HasColumnName("update_by")
                    .HasComment("更新者");
        
                entity.Property(e => e.UpdateTime)
                    .HasColumnName("update_time")
                    .HasComment("更新时间");
            });
        
            modelBuilder.Entity<SysRole>(entity =>
            {
                entity.HasQueryFilter(t=>t.DelFlag == 0);
                entity.HasKey(e => e.RoleId)
                    .HasName("PK__sys_role__760965CC8BF6DEBE");
        
                entity.ToTable("sys_role");
        
                entity.HasComment("角色信息表");
        
                entity.Property(e => e.RoleId)
                    .ValueGeneratedOnAdd()
                    .HasColumnName("role_id")
                    .HasComment("角色ID");
        
                entity.Property(e => e.CreateBy)
                    .HasMaxLength(64)
                    .HasColumnName("create_by")
                    .HasComment("创建者");
        
                entity.Property(e => e.CreateTime)
                    .HasColumnName("create_time")
                    .HasComment("创建时间");
        
                entity.Property(e => e.DataScope)
                    .HasMaxLength(1)
                    .HasColumnName("data_scope")
                    .IsFixedLength(true)
                    .HasComment("数据范围（1：全部数据权限 2：自定数据权限 3：本部门数据权限 4：本部门及以下数据权限）");
        
                entity.Property(e => e.DelFlag)
                    .HasMaxLength(1)
                    .HasColumnName("del_flag")
                    .IsFixedLength(true)
                    .HasComment("删除标志（0代表存在 2代表删除）");
        
                entity.Property(e => e.DeptCheckStrictly)
                    .HasColumnName("dept_check_strictly")
                    .HasComment("部门树选择项是否关联显示");
        
                entity.Property(e => e.MenuCheckStrictly)
                    .HasColumnName("menu_check_strictly")
                    .HasComment("菜单树选择项是否关联显示");
        
                entity.Property(e => e.Remark)
                    .HasMaxLength(500)
                    .HasColumnName("remark")
                    .HasComment("备注");
        
                entity.Property(e => e.RoleKey)
                    .IsRequired()
                    .HasMaxLength(100)
                    .HasColumnName("role_key")
                    .HasComment("角色权限字符串");
        
                entity.Property(e => e.RoleName)
                    .IsRequired()
                    .HasMaxLength(30)
                    .HasColumnName("role_name")
                    .HasComment("角色名称");
        
                entity.Property(e => e.RoleSort)
                    .HasColumnName("role_sort")
                    .HasComment("显示顺序");
        
                entity.Property(e => e.Status)
                    .IsRequired()
                    .HasMaxLength(1)
                    .HasColumnName("status")
                    .IsFixedLength(true)
                    .HasComment("角色状态（0正常 1停用）");
        
                entity.Property(e => e.UpdateBy)
                    .HasMaxLength(64)
                    .HasColumnName("update_by")
                    .HasComment("更新者");
        
                entity.Property(e => e.UpdateTime)
                    .HasColumnName("update_time")
                    .HasComment("更新时间");
            });
        
            modelBuilder.Entity<SysRoleDept>(entity =>
            {
                entity.HasKey(e => new { e.RoleId, e.DeptId })
                    .HasName("PK__sys_role__2BC3005BAF709CA3");
        
                entity.ToTable("sys_role_dept");
        
                entity.HasComment("角色和部门关联表");
        
                entity.Property(e => e.RoleId)
                    .HasColumnName("role_id")
                    .HasComment("角色ID");
        
                entity.Property(e => e.DeptId)
                    .HasColumnName("dept_id")
                    .HasComment("部门ID");
            });
        
            modelBuilder.Entity<SysRoleMenu>(entity =>
            {
                entity.HasKey(e => new { e.RoleId, e.MenuId })
                    .HasName("PK__sys_role__A2C36A61E2B6CA34");
        
                entity.ToTable("sys_role_menu");
        
                entity.HasComment("角色和菜单关联表");
        
                entity.Property(e => e.RoleId)
                    .HasColumnName("role_id")
                    .HasComment("角色ID");
        
                entity.Property(e => e.MenuId)
                    .HasColumnName("menu_id")
                    .HasComment("菜单ID");
            });
        
            modelBuilder.Entity<SysUser>(entity =>
            {
                entity.HasQueryFilter(e=>e.DelFlag == 0);
                entity.HasKey(e => e.UserId)
                    .HasName("PK__sys_user__B9BE370FF377D99F");
        
                entity.ToTable("sys_user");
        
                entity.HasComment("用户信息表");
        
                entity.Property(e => e.UserId)
                    .ValueGeneratedNever()
                    .HasColumnName("user_id")
                    .HasComment("用户ID");
        
                entity.Property(e => e.Avatar)
                    .HasMaxLength(100)
                    .HasColumnName("avatar")
                    .HasComment("头像地址");
        
                entity.Property(e => e.CreateBy)
                    .HasMaxLength(64)
                    .HasColumnName("create_by")
                    .HasComment("创建者");
        
                entity.Property(e => e.CreateTime)
                    .HasColumnName("create_time")
                    .HasComment("创建时间");
        
                entity.Property(e => e.DelFlag)
                    .HasColumnName("del_flag")
                    .HasComment("删除标志（0代表存在 2代表删除）");
        
                entity.Property(e => e.DeptId)
                    .HasColumnName("dept_id")
                    .HasComment("部门ID");
        
                entity.Property(e => e.Email)
                    .HasMaxLength(50)
                    .HasColumnName("email")
                    .HasComment("用户邮箱");
        
                entity.Property(e => e.LoginDate)
                    .HasColumnName("login_date")
                    .HasComment("最后登录时间");
        
                entity.Property(e => e.LoginIp)
                    .HasMaxLength(128)
                    .HasColumnName("login_ip")
                    .HasComment("最后登录IP");
        
                entity.Property(e => e.NickName)
                    .IsRequired()
                    .HasMaxLength(30)
                    .HasColumnName("nick_name")
                    .HasComment("用户昵称");
        
                entity.Property(e => e.Password)
                    .HasMaxLength(100)
                    .HasColumnName("password")
                    .HasComment("密码");
        
                entity.Property(e => e.Phonenumber)
                    .HasMaxLength(11)
                    .HasColumnName("phonenumber")
                    .HasComment("手机号码");
        
                entity.Property(e => e.Remark)
                    .HasMaxLength(500)
                    .HasColumnName("remark")
                    .HasComment("备注");
        
                entity.Property(e => e.Sex)
                    .HasMaxLength(1)
                    .HasColumnName("sex")
                    .HasComment("用户性别（1男 0女 2未知）");
        
                entity.Property(e => e.Status)
                    .HasDefaultValue(1)
                    .HasColumnName("status")
                    .HasComment("帐号状态（1正常 0停用）");
        
                entity.Property(e => e.UpdateBy)
                    .HasMaxLength(64)
                    .HasColumnName("update_by")
                    .HasComment("更新者");
        
                entity.Property(e => e.UpdateTime)
                    .HasColumnName("update_time")
                    .HasComment("更新时间");
        
                entity.Property(e => e.UserName)
                    .IsRequired()
                    .HasMaxLength(30)
                    .HasColumnName("user_name")
                    .HasComment("用户账号");
        
                entity.Property(e => e.UserType)
                    .HasMaxLength(2)
                    .HasColumnName("user_type")
                    .HasComment("用户类型（00系统用户）");
            });
        
            modelBuilder.Entity<SysUserPost>(entity =>
            {
                entity.HasKey(e => new { e.UserId, e.PostId })
                    .HasName("PK__sys_user__CA534F79BCD40A73");
        
                entity.ToTable("sys_user_post");
        
                entity.HasComment("用户与岗位关联表");
        
                entity.Property(e => e.UserId)
                    .HasColumnName("user_id")
                    .HasComment("用户ID");
        
                entity.Property(e => e.PostId)
                    .HasColumnName("post_id")
                    .HasComment("岗位ID");
            });
        
            modelBuilder.Entity<SysUserRole>(entity =>
            {
                entity.HasKey(e => new { e.UserId, e.RoleId })
                    .HasName("PK__sys_user__6EDEA153FA611067");
        
                entity.ToTable("sys_user_role");
        
                entity.HasComment("用户和角色关联表");
        
                entity.Property(e => e.UserId)
                    .HasColumnName("user_id")
                    .HasComment("用户ID");
        
                entity.Property(e => e.RoleId)
                    .HasColumnName("role_id")
                    .HasComment("角色ID");
            });
        
            OnModelCreatingPartial(modelBuilder);
        }

        partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
    }
}
